package com.woniu.inlet.web;

import com.woniu.outlet.po.*;
import com.woniu.service.IPersonBusinessService;
import com.woniu.util.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/cli")
@Api(tags = "个人用户的业务办理")
public class PersonBusinessController {

    @Autowired
    private IPersonBusinessService personBusinessService;

    //查看个人用户的银行卡的信息
    @ApiImplicitParams({
            @ApiImplicitParam(value = "客户经理id",name = "wokerid",required = true,paramType = "query",dataType = "Integer"),
            @ApiImplicitParam(value = "对私客户id",name = "personid",required = false,paramType = "query",dataType = "Integer")
    })
    @ApiOperation(value = "findpersoncard",notes = "查看个人用户的银行卡的信息")
    @GetMapping("/findpersoncard")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<PersonCard>> findpersoncard(Integer wokerid,Integer personid){
        List<PersonCard> findpersoncard = personBusinessService.findpersoncard(wokerid, personid);
        return new ResponseResult<>(findpersoncard,200);

    }

    //查看个人大的银行卡交易记录
    @ApiImplicitParams({
            @ApiImplicitParam(value = "对私人客户的银行卡账号", name = "personcardNum", required = true,paramType = "query",dataType = "String")
    })
    @ApiOperation(value = "findPersonCardTransfer",notes = "查看个人大的银行卡交易记录")
    @GetMapping("/findPersonCardTransfer")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<PersonCardTransfer>> findPersonCardTransfer(String personcardNum){
        List<PersonCardTransfer> personCardTransfer = personBusinessService.findPersonCardTransfer(personcardNum);
        return new ResponseResult<>(personCardTransfer,200);
    }


    //查看个人的活期账户信息
    @ApiImplicitParams({
            @ApiImplicitParam(value = "客户经理id",name = "wokerid",required = true,paramType = "query",dataType = "Integer"),
            @ApiImplicitParam(value = "对私客户id",name = "personid",required = false,paramType = "query",dataType = "Integer")
    })
    @ApiOperation(value = "findPersonCurrentAccount",notes = "查看个人的活期账户信息")
    @GetMapping("/findPersonCurrentAccount")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<PersonCurrentAccount>> findPersonCurrentAccount(Integer wokerid,Integer personid){
        List<PersonCurrentAccount> personCurrentAccount = personBusinessService.findPersonCurrentAccount(wokerid, personid);
        return new ResponseResult<>(personCurrentAccount,200);
    }

    //查看个人的活期账户的交易记录
    @ApiImplicitParams({
            @ApiImplicitParam(value = "个人的活期账户", name = "personcurrentAccount", required = true,paramType = "query",dataType = "String")
    })
    @ApiOperation(value = "findPersonCurrentTransfer",notes = "查看个人的活期账户的交易记录")
    @GetMapping("/findPersonCurrentTransfer")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<PersonCurrentTransfer>> findPersonCurrentTransfer(String personcurrentAccount){
        List<PersonCurrentTransfer> personCurrentTransfer = personBusinessService.findPersonCurrentTransfer(personcurrentAccount);
        return new ResponseResult<>(personCurrentTransfer,200);
    }

    //查看个人的定期的账户
    @ApiImplicitParams({
            @ApiImplicitParam(value = "客户经理id",name = "wokerid",required = true,paramType = "query",dataType = "Integer"),
            @ApiImplicitParam(value = "对私客户id",name = "personid",required = false,paramType = "query",dataType = "Integer")
    })
    @ApiOperation(value = "findPersonRegularAccount",notes = "查看个人的定期的账户")
    @GetMapping("/findPersonRegularAccount")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<PersonRegularAccount>> findPersonRegularAccount(Integer wokerid,Integer personid){
        List<PersonRegularAccount> personRegularAccount = personBusinessService.findPersonRegularAccount(wokerid, personid);
        return new ResponseResult<>(personRegularAccount,200);
    }

    //查看个人定期账户的交易记录
    @ApiImplicitParams({
            @ApiImplicitParam(value = "个人定期账户", name = "personregularAccount", required = true,paramType = "query",dataType = "String")
    })
    @ApiOperation(value = "findPersonRegularTransfer",notes = "查看个人定期账户的交易记录")
    @GetMapping("/findPersonRegularTransfer")
    @PreAuthorize("hasRole('client')")
    public ResponseResult<List<PersonRegularTransfer>> findPersonRegularTransfer(String personregularAccount){
        List<PersonRegularTransfer> personRegularTransfer = personBusinessService.findPersonRegularTransfer(personregularAccount);
        return new ResponseResult<>(personRegularTransfer,200);
    }


}
